package avicit.bdp.dgs.qa.utils.enums;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2023-03-30
 * @类说明：SubscribeType
 * @修改记录：
 * @注意事项：
 * @主要功能：质量作业订阅类型
 */
public enum SubscribeType {
    MANUAL(0, "电话"),
    PERIOD(1, "邮件"),
    SYS_MSG(2, "系统消息");

    private final int code;

    private final String desc;

    SubscribeType(int code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(Integer code) {
        if (code != null) {
            SubscribeType[] values = SubscribeType.values();
            for (SubscribeType resourceType : values) {
                if (resourceType.getCode() == code) {
                    return resourceType.getDesc();
                }
            }
        }

        return null;
    }

    public static SubscribeType getTypeByCode(Integer code) {
        if (code != null) {
            SubscribeType[] values = SubscribeType.values();
            for (SubscribeType resourceType : values) {
                if (resourceType.getCode() == code) {
                    return resourceType;
                }
            }
        }

        return null;
    }
}
